package com.atguigu.jxc.service.impl;

import com.atguigu.jxc.dao.UnitDao;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.entity.Unit;
import com.atguigu.jxc.service.UnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author dxt
 * @create 2025-07-16-15:04
 */
@Service
public class UnitServiceImpl implements UnitService {

    @Autowired
    private UnitDao unitDao;

    /**
     * 查询所有商品单位
     * @return
     */
    @Override
    public Map<String, Object> getUnitList() {
        HashMap<String, Object> result = new HashMap<>();
        List<Unit> list = unitDao.selectListPage();
        result.put("rows", list);
        return result;
    }

    /**
     * 添加商品单位
     * @param unitName
     */
    @Override
    public void saveUnit(String unitName) {
        unitDao.saveUnit(unitName);
    }

    /**
     * 删除商品单位
     * @param unitId
     */
    @Override
    public void deleteUnit(Integer unitId) {
        unitDao.deleteUnit(unitId);
    }
}
